#include <sstream>
#include "transaction.h"

using namespace std;
using namespace stock_trade;
bool Transaction::operator<(const Transaction& transaction) const
{
    if (this->date < transaction.date)
        return true;
    if (this->date > transaction.date)
        return false;
    //same date
    if (this->time < transaction.time)
        return true;
    if (this->time > transaction.time)
        return false;
    return false;
}

string Transaction::ToString() const
{
    ostringstream oss;
    string actionString;
    if (action == BUY)
        actionString = "BUY";
    if (action == SELL)
        actionString = "SELL";
    if (action == NONE)
        actionString = "NONE";

    oss << stock.name << " "
        << stock.code << " "
        << date       << " "
        << time       << " "
        << price      << " "
        << number     << " "
        << type       << " "
        << status     << " "
        << actionString;
    return oss.str();
}
